package app.cn.com.school.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import app.cn.com.school.R
import app.cn.com.school.config.AppContext
import app.cn.com.school.databinding.ActivitySettingBinding
import app.cn.com.school.tools.FilesUtlis
import app.cn.com.school.tools.SharedPreferenceUtil

class SettingActivity : BaseActivity<ActivitySettingBinding>() {
    override fun initBindingVar() {
    }

    override fun initTitle() {
        binding.titlebar.title.text = "设置"
        binding.titlebar.back.setOnClickListener { finish() }
    }

    lateinit var context: Context
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initBinding(R.layout.activity_setting)
        context = this
        initView()
    }

    private fun initView() {
        binding.setAllCache.text = FilesUtlis.getTotalCacheSize(context)
        binding.setVersion.text = FilesUtlis.getVersion(context)
        binding.outLogin.setOnClickListener {
            //退出登录
            SharedPreferenceUtil.clear()
            AppContext.getInstance().logoutApp()
            finish()
        }

        binding.setUsers.setOnClickListener {
            //关于我们

        }

        binding.userOpinion.setOnClickListener {
            //意见反馈

        }

        binding.setAllCache.setOnClickListener {
            //清楚缓存
            FilesUtlis.clearAllCache(context)
            binding.setAllCache.text = "0M"
        }

        binding.setUpdatePwd.setOnClickListener {
            //密码设置
            startActivity(Intent(context, SetPwdActivity::class.java))
        }

        binding.setAddress.setOnClickListener {
            //地址管理
            startActivity(Intent(context, AddressActivity::class.java))
        }

    }


}
